package parser

import (
	"regexp"
	"strconv"
	"wjerp.com/hello/crawler/engine"
)

const purpleRe = `<div class="des f-cl" data-v-4c07f04e>([^|]*)| ([0-9]+)岁 | ([^|]*)| ([^|]*)| ([0-9]+)cm | ([^<]*)</div>`


func ParseProfile(contents []byte,name string) engine.ParseResult{
	regex := regexp.MustCompile(cityRe)
	submatch := regex.FindSubmatch(contents)
	profileInfo := engine.Profile{
		Nickname: name,
		City: string(submatch[1]),
		XueLi: string(submatch[3]),
		HunYin: string(submatch[4]),
		Income: string(submatch[6]),
	}

	age, err := strconv.Atoi(string(submatch[2]))
	if err != nil {
		profileInfo.Age = age
	}
	height, err := strconv.Atoi(string(submatch[5]))
	if err != nil {
		profileInfo.Height = height
	}

	parseResult:=engine.ParseResult{
		Items:[]interface{} {profileInfo},
	}
	return parseResult

}
